<template>
    <el-form label-width="80px">
        <el-form-item label="患者名称:">
            <el-input type="text" v-model="patient.patientName" />
        </el-form-item>
        <el-form-item label="身份证:">
            <el-input type="text" v-model="patient.patientIdnum" />
        </el-form-item>
        <el-form-item label="患者性别:">
            <el-select v-model="patient.patientSex" style="width: 100%" clearable v-loading="loading">
                <el-option label="请选择" value="" disabled></el-option>
                <el-option label="男" value="男"></el-option>
                <el-option label="女" value="女"></el-option>
            </el-select>
        </el-form-item>
        <el-form-item label="确认操作:">
            <el-button style="width: 100%" @click="addPatient">
                确认修改
            </el-button>
        </el-form-item>
    </el-form>
</template>

<script>
    import utils from "@/Utils";
    export default {
        name: "SystemPopupAddPatient",
        data(){
            return{
                patient:{
                    patientName:'',
                    patientIdnum:'',
                    patientSex:'',
                },
                loading:false,
                utils
            }
        },
        methods:{
            addPatient:function () {
                const patient=this.patient;
                if (this.utils.isEmpty(patient.patientIdnum, patient.patientName, patient.patientSex)) {
                    this.utils.tipsMessage("请不要留空..",1);
                    return
                }
                if (patient.patientIdnum.length !== 18) {
                    this.utils.tipsMessage("请输入十八位的身份证..",1);
                    return
                }
                this.loading=true;
                this.axios.post("/Patient/isLogin/isSystemAndDoctor/addPatient",{
                    patientName:patient.patientName,
                    patientIdnum:patient.patientIdnum,
                    patientSex:patient.patientSex
                }).then((req)=>{
                    const data=req.data;
                    if(data.code>0){
                        this.utils.tipsMessage(data.error,data.code);
                        return
                    }
                    this.utils.tipsMessage(data.data,data.code);
                    this.patient={
                        patientName:'',
                        patientIdnum:'',
                        patientSex:'',
                    }
                }).then(()=>{
                    this.loading=false;
                });
            }
        }
    }
</script>

<style scoped>

</style>